package Ep02_LinkedList._0206;

import Ep02_LinkedList.ListNode;

/**
 * @author Jimmy Zhan WORKSTATION
 * @date 2023/3/7 10:28
 * 说明：力扣 0206 翻转链表  --->  双指针解法，在原有链表上操作，不会造成额外内存开销
 */

public class DoublePointer {
    public ListNode reverseList(ListNode head){
        ListNode pre = null;
        ListNode cur = head;
        ListNode temp = null;

        while(cur!=null){
            temp = cur.next;
            cur.next = pre;
            pre = cur;
            cur = temp;
        }
    return pre;
    }
}
